/**
 * 
 */
package com.google.code.onlineshopping4j.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author TelmilaJ
 *
 */
@Entity
@Table(name="product")
public class Product extends BaseModel implements Serializable {
	
	private static final long serialVersionUID = -2324594548388581441L;

	@Column(name = "name", nullable=false)
	private String name;

	@Column(name = "price", nullable=false)
	private Double price;
	
	@ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "currency", nullable=false)
	private Currency currency;
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy="product")
	private List<ProductImage> productImages = null;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public List<ProductImage> getProductImages() {
		if (productImages == null) {
			productImages = new ArrayList<ProductImage>();
		}
		return productImages;
	}

	public void setProductImages(List<ProductImage> productImages) {
		this.productImages = productImages;
	}
}
